﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Input;

namespace X3DXamlXna
{
    public interface IProximityComponent
    {
        void Add(BoundingBox box);
    }

    public class ProximityComponent : GameComponent, IProximityComponent
    {
        private List<BoundingBox> boxes = new List<BoundingBox>();

        public ProximityComponent(Game game)
            : base(game)
        {
            game.Services.AddService(typeof(IProximityComponent), this);

        }

        public override void Initialize()
        {
           base.Initialize();
        }

        public override void Update(GameTime gameTime) 
        {
            var effect = (Game.Services.GetService(typeof(IDrawableModel)) as IDrawableModel).effect;
            //System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.Arrow;
            
            var cameras = (Game.Services.GetService(typeof(ICameraService)) as ICameraService);

            foreach (var sensor in boxes)
            {
                if (sensor.Contains(cameras.CurrentCamera.position) == ContainmentType.Contains)
                {
                    //System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.Cross;
                    Console.WriteLine("Inside Proximity Sensor");
                }

            }

            base.Update(gameTime);
        }

        public void Add(BoundingBox box)
        {
            boxes.Add(box);
        }
    }
}

